package cn.hxzy.mapper;

import cn.hxzy.domain.Exercises;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.parsing.Problem;

import java.util.List;

/**
 * 项目名: education-platform
 * 当前用户: 18735
 * 创建日期: 2024/6/27 下午4:40
 * 项目介绍:
 */
@Mapper
public interface ProblemMapper extends BaseMapper<Exercises> {
    @Select("select * from sys_exercises where course_id=#{courseId}")
    List<Exercises> getProblemListByTeacherId(Long teacherId);

    @Select({
            "<script>",
            "select * from sys_exercises",
            "<if test='teacherId != null'>",
            "    and teacher_id = #{teacherId}",
            "</if>",
            "<if test='classId != null'>",
            "    and class_id = #{classId}",
            "</if>",
            "<if test='courseId != null'>",
            "    and course_id = #{courseId}",
            "</if>",
            "<if test='chapterId != null'>",
            "    and chapter_id = #{chapterId}",
            "</if>",
            "</script>"
    })
    List<Exercises> getProblemList(@Param("classId") Long classId,@Param("courseId") Long courseId,@Param("chapterId") Long chapterId,@Param("teacherId") Long teacherId);

    @Select("select * from sys_exercises where course_id=#{courseId}")
    List<Exercises> getProblemListByName(String studentName);
}
